<template>
	<view class="mainpadding2" style="padding-bottom: 150rpx;">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="xiahuaxian margin_top" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="shilitu">
					<image :src="item.image_text" class="radius" mode=""></image>
				</view>
				<view class="" style="width: 69%;">
					<view class="titletext xiaohei fonweight yhxk">{{item.name}}</view>
					<view class="strongtext xiaohui nofonweight margin_right2 margin_top2">开始时间：{{item.bm_starttime_text}}</view>
					<view class="strongtext xiaohui nofonweight margin_right2 margin_top2">结束时间：{{item.bm_endtime_text}}</view>
				</view>
			</view>
			<view class="flexright margin_top2">
				<view class="baibtn margin_right2" @click="delitem(item.id)">移除</view>
				<view class="lanbtn margin_right2" @click="jumpurl('/pages_mypage/saishibmxx?id=',item.id)">查看报名信息</view>
				<view class="lvbtn" @click="jumpurl('/pages_mypage/saishitj?id=',item.id)">编辑</view>
			</view>
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="jumpurlxj('/pages_mypage/saishitj','')">新建赛事</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				modal:{
					modalShow:false,
					title:"是否确认删除当前赛事？",
				},
				currentid:"",
				user_zbfapply_listid:""
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid=options.user_zbfapply_listid
		},
		onShow() {
			this.init()
		},
		methods: {
			delitem(id){
				this.modal.modalShow = true
				this.currentid = id
			},
			modalSure(){
				if(this.modal.title=="是否确认删除当前赛事？"){
					httpRequest.request("/api/sscl/deleteSs", 'GET', {
						id:this.currentid,
						user_zbfapply_id:this.user_zbfapply_listid
					}).then(res => {
						httpRequest.toast(res.msg)
						if(res.code==1){
							this.init()
						}
					})
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				let url = '/api/sscl/mySsIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url,id){
				uni.navigateTo({
					url:url+id+"&user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
			jumpurlxj(url){
				uni.navigateTo({
					url:url+"?user_zbfapply_listid="+this.user_zbfapply_listid
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.shilitu {
		width: 200rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>
